﻿<cfscript>
/** 
* DataBase Frameworks - Sequence
* 
* @hint "DataBase Frameworks - Sequence - Campus" 
*/ 

component 
	displayname="public.service.db.senate.sequence.Campus" 
	output=false 
	accessors=true 
	{

	/**
	* @hint "初始化对象"
	*/
	public function init() output=false {
		return this;
	}
	
	/**
	* @hint "自定义主键规则"
	*/
	public string function getID() output=false {
		
		var nextID = numberFormat(1, "0_");

		var sql = "	SELECT
						c.campus_id
					FROM
						t_campus c
					ORDER BY
						c.campus_id DESC";
		
		var queryObj = new Query(datasource = application.dnsMaster, maxRows = 1);
		var rs_check = queryObj.execute(sql = sql).getResult();
		
		/* 
			主键生成规则 CHAR(2)
			
			2位为流水号 校区自动编码
		*/
		if (rs_check.recordCount) {
			/* 创建一个追加id */
			nextID = numberFormat((rs_check.campus_id + 1), "0_");
			
		}

		return nextID;
	}

}

</cfscript>